<template>
  <div class="baidumap" id="mapLine"></div>
</template>
<script>
import styleJson from "@/tools/custom_map_config";
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      mapStyle: {
        styleJson: styleJson,
      },
      currentPoint: {},
    };
  },
  computed: {
    ...mapGetters({
      user: "user",
    }),
  },
  mounted() {
    this.initMap();
  },
  methods: {
    initMap() {
      this.map = new BMap.Map("mapLine"); //创建地图实例
      let point = new BMap.Point(this.$route.query.lng, this.$route.query.lat); // 创建点坐标
      this.map.centerAndZoom(point, 14); // 初始化地图，设置中心点坐标和地图级别
      this.map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
      this.map.clearOverlays();
      this.map.setMapStyleV2(this.mapStyle);
      this.getMyLocationAndSign();
    },
    getMyLocationAndSign() {
      let _this = this;
      let geolocation = new BMap.Geolocation(); // 定位当前位置
      geolocation.getCurrentPosition(
        function (r) {
            console.log(r)
          if (this.getStatus() == BMAP_STATUS_SUCCESS) {
            console.log("经纬度" + r.point.lat, r.point.lng);
          
            console.log(driving)
          } else {
            _this.$message("failed" + this.getStatus());
          }
        },
        {
          enableHighAccuracy: true,
        }
      );
    },
  },
};
</script>
<style lang="less" scoped>
#mapLine {
  width: 100%;
  height: 500px;
}
</style>